@extends('layout.master')
@section('content')
<div class="right_col" role="main">
<div class="">
<div class="page-title">
<div class="title_left">
<h3>Customer Profile</h3>
</div>
{{-- <div class="title_right">
<div class="col-md-5 col-sm-5 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-secondary" type="button">Go!</button>
</span>
</div>
</div>
</div> --}}
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<h2>Customer Details
<small>
@if ($customer->status == 'active')
<span class="badge badge-success text-white">Active</span>
@elseif ($customer->status == 'inactive')
<span class="badge badge-secondary text-white">Inactive</span>
@elseif ($customer->status == 'suspended')
<span class="badge badge-warning text-white">Suspended</span>
@endif
</small>
</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-md-3 col-sm-3 profile_left">
<div class="profile_img">
<div id="crop-avatar">
<!-- Current avatar -->
<img class="img-responsive avatar-view"
src="{{ $customer->image ? asset('storage/' . $customer->image) : asset('images/user.png') }}"
alt="Customer Avatar" title="Customer Image"
style="width:150px; height:150px; object-fit:cover;">
</div>
</div>
<h3>
{{ $customer->first_name }} {{ $customer->last_name }}
</h3>
<ul class="list-unstyled user_data">
<li>
<i class="fa fa-envelope user-profile-icon"></i>
<strong>Email:</strong> {{ $customer->email }}
</li>
<li>
<i class="fa fa-phone user-profile-icon"></i>
<strong>Phone:</strong> {{ $customer->phone }}
</li>
@if ($customer->alternative_phone)
<li>
<i class="fa fa-phone user-profile-icon"></i>
<strong>Alt Phone:</strong> {{ $customer->alternative_phone }}
</li>
@endif
@if ($customer->date_of_birth)
<li class="m-top-xs">
<i class="fa fa-birthday-cake user-profile-icon"></i>
<strong>Age:</strong>
{{ \Carbon\Carbon::parse($customer->date_of_birth)->age }}
years
</li>
@endif
<li>
<i class="fa fa-user user-profile-icon"></i>
<strong>Gender:</strong> {{ ucfirst($customer->gender) }}
</li>
</ul>
<div class="justify-content-between">
<a href="{{ route('admin.customer.edit', $customer->id) }}"
class="btn btn-primary btn-sm"><i class="fa fa-edit m-right-xs"></i> Edit
Profile
</a>
</div>
<br />
</div>
<div class="col-md-9 col-sm-9 ">
<div class="" role="tabpanel" data-example-id="togglable-tabs">
<ul id="myTab" class="nav nav-tabs bar_tabs" role="tablist">
{{-- <li role="presentation" class="active"><a href="#tab_content1" id="home-tab"
role="tab" data-toggle="tab" aria-expanded="true">Recent Activity</a>
</li> --}}
<li role="presentation" class="active"><a href="#tab_content2" role="tab"
id="profile-tab" data-toggle="tab" aria-expanded="false">Booking
Details</a>
</li>
{{-- <li role="presentation" class=""><a href="#tab_content3" role="tab"
id="profile-tab2" data-toggle="tab" aria-expanded="false">Profile</a>
</li> --}}
</ul>
<div id="myTabContent" class="tab-content">
<div role="tabpanel" class="tab-pane active table-responsive" id="tab_content2"
aria-labelledby="profile-tab">
<!-- start customer bookings -->
<table
class="table table-striped table-bordered dt-responsive nowrap jambo_table bulk_action">
<thead>
<tr>
<th>#</th>
<th>Booking Code</th>
<th>Ride Type</th>
<th>Booking Type</th>
{{-- <th>Locations</th>
<th>Date</th> --}}
<th>Distance</th>
<th>Total Amount</th>
<th>Status</th>
</tr>
</thead>
<tbody>
@forelse($bookings as $index => $booking)
<tr>
<td>{{ $bookings->firstItem() + $index }}</td>
<td>
<a
href="{{ route('admin.booking.view', encrypt($booking->id)) }}">
{{ $booking->booking_code }}
</a>
</td>
<td>{{ $booking->ride_type_name }}</td>
<td>{{ $booking->booking_type == 1 ? 'One Way' : 'Two Way' }}
</td>
{{-- <td>
@php
$pickup =
$booking->locations['pickup_location'] ?? null;
$drop =
$booking->locations['drop_location'] ?? null;
@endphp
@if ($pickup && $drop)
{{ $pickup }} <br>to<br> {{ $drop }}
@elseif($pickup)
{{ $pickup }}
@elseif($drop)
{{ $drop }}
@else
-
@endif
</td> --}}
{{-- <td>
@php
$fromDate = \Carbon\Carbon::parse(
$booking->dates['from_date'],
)->format('d-m-Y');
$toDate = $booking->dates['to_date'] ?? null;
@endphp
{{ $toDate ? $fromDate . ' to ' . \Carbon\Carbon::parse($toDate)->format('d-m-Y') : $fromDate }}
</td> --}}
<td>
@php $ride = $booking->rides->first(); @endphp
{{ $ride?->distance_km ? $ride->distance_km . ' km' : '-' }}
</td>
<td>₹ {{ $booking->total_customer_amount }} </td>
<td>
@php
$status = $booking->booking_status;
$badgeClass = match ($status) {
'pending' => 'badge bg-warning text-white',
'assigned' => 'badge bg-info text-white',
'ongoing' => 'badge bg-primary text-white',
'in_progress'
=> 'badge bg-secondary text-white',
'completed'
=> 'badge bg-success text-white',
'cancelled' => 'badge bg-danger text-white',
default => 'badge bg-light text-white',
};
@endphp
<span class="{{ $badgeClass }}">
{{ ucfirst(str_replace('_', ' ', $status)) }}
</span>
</td>
</tr>
@empty
<tr>
<td colspan="7" class="text-center text-muted">No Booking
Details</td>
</tr>
@endforelse
</tbody>
</table>
<div class="mt-3">
<ul class="pagination justify-content-end">
@if ($bookings->onFirstPage())
<li class="page-item disabled"><span
class="page-link">Prev</span>
</li>
@else
<li class="page-item"><a class="page-link"
href="{{ $bookings->previousPageUrl() }}">Prev</a></li>
@endif
@for ($i = 1; $i <= $bookings->lastPage(); $i++)
<li
class="page-item {{ $bookings->currentPage() == $i ? 'active' : '' }}">
<a class="page-link"
href="{{ $bookings->url($i) }}">{{ $i }}</a>
</li>
@endfor
@if ($bookings->hasMorePages())
<li class="page-item"><a class="page-link"
href="{{ $bookings->nextPageUrl() }}">Next</a></li>
@else
<li class="page-item disabled"><span
class="page-link">Next</span>
</li>
@endif
</ul>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="tab_content3"
aria-labelledby="profile-tab">
<p>xxFood truck fixie locavore, accusamus mcsweeney's marfa nulla
single-origin
coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings
next
level wes anderson artisan four loko farm-to-table craft beer twee. Qui
photo booth letterpress, commodo enim craft beer mlkshk </p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('script')
<script>
$(document).on('click', '.verify-doc', function() {
let docId = $(this).data('id');
let button = $(this);
Swal.fire({
title: 'Are you sure?',
text: "Mark this document as verified?",
icon: 'question',
showCancelButton: true,
confirmButtonText: 'Yes, verify it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: '/admin/customer/document/' + docId + '/verify',
method: 'POST',
data: {
_token: '{{ csrf_token() }}'
},
success: function(res) {
Swal.fire('Verified!', res.message, 'success').then(() => {
location.reload();
});
},
error: function(err) {
Swal.fire('Error', 'Something went wrong', 'error');
}
});
}
});
});
$(document).on('click', '.delete-doc', function() {
let docId = $(this).data('id');
let card = $('#doc-card-' + docId);
Swal.fire({
title: 'Are you sure?',
text: "This document will be permanently deleted!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#6c757d',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'Cancel'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: '/admin/customer/document/delete/' + docId,
type: 'DELETE',
data: {
_token: '{{ csrf_token() }}'
},
success: function(response) {
if (response.success) {
card.remove();
Swal.fire(
'Deleted!',
response.message,
'success'
).then(() => {
location.reload();
});
} else {
Swal.fire(
'Error!',
'Something went wrong.',
'error'
);
}
},
error: function() {
Swal.fire(
'Error!',
'Unable to delete document.',
'error'
);
}
});
}
});
});
$(document).on('click', '.verify-customer', function() {
const $btn = $(this);
const driverId = $btn.data('id');
const isVerified = $btn.data('verified') == 1;
const actionText = isVerified ? 'unverify' : 'verify';
Swal.fire({
title: 'Are you sure?',
text: `Do you want to ${actionText} this customer?`,
icon: 'question',
showCancelButton: true,
confirmButtonText: `Yes, ${actionText} it!`
}).then((result) => {
if (!result.isConfirmed) return;
$.ajax({
url: '/admin/customer/' + driverId + '/verify',
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
},
data: {
status: isVerified ? 0 : 1
},
success: function(res) {
Swal.fire('Success!', res.message || 'Status updated', 'success');
// Toggle status
$btn.data('verified', isVerified ? 0 : 1);
$btn.text(isVerified ? 'Verify Customer' : 'Unverify Customer');
$btn.toggleClass('btn-success btn-danger');
},
error: function(xhr) {
let msg = 'Something went wrong';
if (xhr.responseJSON && xhr.responseJSON.message) msg = xhr.responseJSON
.message;
Swal.fire('Error', msg, 'error');
}
});
});
});
</script>
@endpush